<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output
		media-type="text/xml"
		method="xml"
		indent="yes"
		omit-xml-declaration="yes"
		encoding="UTF-8"
		doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>

	<!-- includes the main GXPage stylesheet, which creates variables for common information -->
	<xsl:include href="../../../XSL/gxpage-page.xsl"/>

	<xsl:template match="Page">
		<html>
			<head>
				<xsl:call-template name="showHead"/>

				<script type="text/javascript" src="{$Scripts}jquery-1.1.2.pack.js"></script>
				<script type="text/javascript" src="{$Scripts}gxpage.js"></script>
				<link rel="stylesheet" type="text/css" href="Assets/gxpage.css"/>
			</head>
			<body id="{$Page}">
				<xsl:if test="not($User)">
					<xsl:attribute name="class">anonymous</xsl:attribute>
				</xsl:if>

				<div id="LanguageBox" style="position: relative; text-align: right; top: -12px;">
					<xsl:call-template name="doLang"/>
				</div>

				<xsl:apply-templates select="//gxpage-runtime/Site/SiteTree/PageList"/>
				<div id="Content">

					<xsl:call-template name="showMessageList"/>

					<p>
						<xsl:apply-templates select="/Page/Section[ lang($Language) ]"/>
					</p>

				</div>
				<xsl:call-template name="doFoot"/>

			</body>
		</html>
	</xsl:template>

	<xsl:template match="Section">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="Block">
		<div class="Section">
			<xsl:apply-templates/>
		</div>
	</xsl:template>

	<xsl:template match="Head">
		<xsl:if test="string-length(Content)">
			<div class="Head">
				<xsl:apply-templates/>
			</div>
		</xsl:if>
	</xsl:template>

	<xsl:template match="Title">
		<xsl:if test="string-length(.) &gt; 0">
			<div class="Title">
				<xsl:apply-templates/>
			</div>
		</xsl:if>
	</xsl:template>

	<xsl:template match="Content">
		<p>
			<xsl:value-of select="." disable-output-escaping="yes"/>
		</p>
	</xsl:template>

	<xsl:template match="PageList">
		<div id="Realm">
			<ul>
				<xsl:for-each select="./*[ Group = 'Tabs' ]">
					<li id="nav-{@ID}">
						<a href="{$Self}/{@ID}">
							<xsl:call-template name="i18n">
								<xsl:with-param name="Group" select="'NavTable'"/>
								<xsl:with-param name="Key" select="@ID"/>
							</xsl:call-template>
						</a>
						<xsl:if test="count(PageList/*)">
							<xsl:apply-templates select="PageList"/>
						</xsl:if>
					</li>
				</xsl:for-each>
			</ul>
		</div>
	</xsl:template>

	<xsl:template name="doLang">
		<xsl:choose>
			<xsl:when test="/Page/gxpage-runtime/Site/i18n">
				<xsl:variable name="langs" select="$i18n/*[ name() = 'LangTable' ]/*[ lang($Language) ]"/>
				<select id="LanguageSelector">
					<xsl:for-each select="$langs/*">
						<option value="{@ID}">
							<xsl:if test="@ID = $Language">
								<xsl:attribute name="selected">true</xsl:attribute>
							</xsl:if>
							<xsl:value-of select="."/>
						</option>
					</xsl:for-each>
				</select>
			</xsl:when>
			<xsl:otherwise>
				There are no supported languages for this site
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="doFoot">
		<div id="Footer">
			<div class="AdminBlock">
				<span class="Login">
					<xsl:choose>
						<xsl:when test="$User">
							<span style="color: gray; margin-left: 20px;">
								You are logged in as
								<xsl:value-of select="concat($User/FirstName,' ',$User/LastName)"/>
								<xsl:text>  | </xsl:text>
								<a href="{$Self}/_GX/Logout">log out</a>
							</span>
						</xsl:when>
						<xsl:otherwise>
							<span class="Anonymous" style="margin-left: 20px; color: #cfcfcf;">
								<form id="LoginForm" style="display: inline;" action="{$Self}/_GX/Login" method="post">
									<input type="text" name="Username"/>
									<input type="password" name="Password"/>
								</form>
							</span>
						</xsl:otherwise>
					</xsl:choose>
				</span>
				<!-- collapsible errors -->
				<span class="GXErrors">
					<span class="Indicator"><a href="javascript:void(0)">[+]</a></span>
					<div class="List">
						<xsl:call-template name="showErrorList"/>
					</div>
				</span>
			</div>
		</div>
	</xsl:template>

</xsl:stylesheet>
